package com.movieManager.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.movieManager.bean.bean_cart;
import com.movieManager.bean.bean_movie;
import com.movieManager.impl.myCart;

public class action_shopCart extends DispatchAction{

	public ActionForward getMycart(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		String user_name=request.getParameter("user_name");
		System.out.println("username"+user_name);
		myCart cart=new myCart();
		List<bean_cart> list=cart.getMyCart(user_name);
		List<bean_movie> listmovie=cart.getMovieofCart(list);
		System.out.println("size of listmovei"+listmovie.size());
		JSONArray json=JSONArray.fromObject(listmovie);
		//System.out.println("test cart"+json);
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().print(json);
		return null;
		
	}

}
